package com.vn.ld.common;

public final class Constants {
	// Date Format
	public static final String DATE_FORMAT_SECOND_TRUNCATE = "yyyyMMdd";
	public static final String DATE_FORMAT_FULL = "yyyy-MM-dd HH:mm:ss:SSS";

	public static final Integer SELL_SIDE = 1;
	public static final Integer BUY_SIDE = 2;
	
	//CND those constants should be configurable
	public static final Integer DEF_ORDER_LIST_SIZE = 1000;
	public static final Integer MAX_ORDER_LIST_SIZE = 2000;
	public static final Integer MIN_ORDER_LIST_SIZE = 500;
	
	/**
	 * Date time format config
	 * @author Shark
	 *
	 */
	public static class DateTimeFormat {
		public static final String PATTERN_MMDDYYYY = "mm/dd/yyyy";
		public static final String PATTERN_YYYYMMDD_BLANK = "yyymmdd";
	}
	// ID Counter step
	public static final Integer ID_COUNTER_STEP_DEFAULT = 50;
	
	public static final Integer DBQUEUE_WAIT_EMPTY_TIMEOUT = 5000; //timeout when waiting for Db queue to be emptied in milliseconds
	/**
	 * The Constants OrderStatus.
	 */
	public static class OrderStatus {
		public static final Integer ORDER_STATUS_CANCELLED = 0;
		public static final Integer ORDER_STATUS_PENDING = 1;
		public static final Integer ORDER_STATUS_INPROGRESS = 2;
		public static final Integer ORDER_STATUS_COMPLETED = 3;
	}
	
	public static class OrderInfo {
		public static final String AMMOUNT = "ammount";
		public static final String ACTION  = "action";
		public static final String PRICE_PER = "pricePer";
	} 
	
	/**
	 * The static class contains type of the configurations.
	 */
	public static class ConfigType {
		
		/** The type for configurations of available service types. */
		public static final String SERVICE_TYPE = "ServiceType";
		
		/** The type for configurations of available assets types. */
		public static final String ASSETS_TYPE = "AssetsType";
	}
	
	public static class IdCounterKey {
		public static final String ORDER_ID_COUNTER_KEY = "ORD";
		
		public static final String TRANSACTION_ID_COUNTER_KEY = "TRANS";
		
		public static final String DEPOSIT_ID_COUNTER_KEY = "DEP";
		
		public static final String WITHDRAW_ID_COUNTER_KEY = "WDR";
	}
	
	/**
	 * The ServiceType.
	 */
	public enum ServiceType {
		PLN(1),
		USD(2),
		BTC(100),
		LTC(101);

		/**
		 * Get ServiceType from string.
		 * 
		 * @param name the name
		 * @return the service type
		 */
		public static ServiceType fromString(final String name) {
			return valueOf(name);
		}

		/**
		 * Gets ServiceType by typeId.
		 * 
		 * @param typeId the typeId
		 * @return the ServiceType
		 */
		public static ServiceType getById(final Integer typeId) {
			for (final ServiceType serviceType : ServiceType.values()) {
				if (serviceType.getTypeId().equals(typeId)) {
					return serviceType;
				}
			}
			throw new IllegalArgumentException();
		}

		private Integer typeId;

		private ServiceType(final Integer typeId) {
			this.typeId = typeId;
		}

		public Integer getTypeId() {
			return this.typeId;
		}
	}

	
}
